"""
    panel player
"""
import wx
from data import *



class control_player(wx.BoxSizer):
    
    def __init__(self, parent):
        self.parent = parent
        wx.BoxSizer.__init__(self, wx.HORIZONTAL)
        
        self.bt_prev = wx.BitmapButton(self.parent, -1, wx.Bitmap(player_images["prev"], wx.BITMAP_TYPE_ANY))
        self.bt_stop = wx.BitmapButton(self.parent, -1, wx.Bitmap(player_images["stop"], wx.BITMAP_TYPE_ANY))
        self.bt_play = wx.BitmapButton(self.parent, -1, wx.Bitmap(player_images["play"], wx.BITMAP_TYPE_ANY))
        self.bt_pause = wx.BitmapButton(self.parent, -1, wx.Bitmap(player_images["pause"], wx.BITMAP_TYPE_ANY))
        self.bt_next = wx.BitmapButton(self.parent, -1, wx.Bitmap(player_images["next"], wx.BITMAP_TYPE_ANY))
        
        self.__set_properties()
        self.__do_layout()
        self.__set_actions()
        
        #inspeccionamos lista
        
        
    def __set_properties(self):
        self.bt_prev.SetSize(self.bt_prev.GetBestSize())
        self.bt_stop.SetSize(self.bt_stop.GetBestSize())
        self.bt_play.SetSize(self.bt_play.GetBestSize())
        self.bt_pause.SetSize(self.bt_pause.GetBestSize())
        self.bt_next.SetSize(self.bt_next.GetBestSize())
        
    def __do_layout(self):
        self.Add(self.bt_prev, 0, 0, 0)
        self.Add(self.bt_stop, 0, 0, 0)
        self.Add(self.bt_play, 0, 0, 0)
        self.Add(self.bt_pause, 0, 0, 0)
        self.Add(self.bt_next, 0, 0, 0)
        
    def __set_actions(self):
        self.parent.Bind(wx.EVT_BUTTON, self.handler_prev, self.bt_prev)
        self.parent.Bind(wx.EVT_BUTTON, self.handler_stop, self.bt_stop)
        self.parent.Bind(wx.EVT_BUTTON, self.handler_play, self.bt_play)
        self.parent.Bind(wx.EVT_BUTTON, self.handler_pause, self.bt_pause)
        self.parent.Bind(wx.EVT_BUTTON, self.handler_next, self.bt_next)
    
    def handler_prev(self, event):
        self.parent.Angel.playlist_set_next_rel(-1)
        self.parent.Angel.playback_tickle()
        event.Skip()

    def handler_stop(self, event):
        self.parent.Angel.playback_stop()
        event.Skip()

    def handler_play(self, event):
        self.parent.Angel.playback_start()
        event.Skip()

    def handler_pause(self, event):
        self.parent.Angel.playback_pause()
        event.Skip()

    def handler_next(self, event): 
        self.parent.Angel.playlist_set_next_rel(1)
        self.parent.Angel.playback_tickle()
        event.Skip()
    
    def handler_list_generate(self, result):
        print result
    
    